using FireStarter.CodeGeneration;
using NUnit.Framework;

namespace FireStarter.Test.CodeGeneration
{
    [TestFixture]
    public class TestClassGenerationTestBase
    {
        [Test]
        public void Test_ConstructClassGenerator()
        {
            //---------------Set up test pack-------------------
            string className = TestUtilsCodeGen.GetRandomString();
            string projectName = TestUtilsCodeGen.GetRandomString();
            string projectPath = TestUtilsCodeGen.GetRandomString();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            ClassGenerator classGenerator = new ClassGeneratorTestBase(className, projectName, projectPath);

            //---------------Test Result -----------------------
            Assert.AreEqual(className + ".cs", classGenerator.FileName);
            Assert.AreEqual(className, classGenerator.ClassName);
            Assert.AreEqual(projectName, classGenerator.ProjectName);
            Assert.AreEqual(projectPath, classGenerator.ProjectPath);
        }

        [Test]
        public void Test_Construct()
        {
            //The construct for this class does nothing since
            // there are no sub objects for this class.
            //---------------Set up test pack-------------------
            ClassGeneratorTestBase classGenerator = CreateNewClassGenerator();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            classGenerator.Construct();

            //---------------Test Result -----------------------
        }

        [Test]
        public void Test_Compile()
        {
            //The Compile method should compile the Tags of the format
            // <<Tag>> with the replacement string or template
            // as appropriate.
            //---------------Set up test pack-------------------
            ClassGeneratorTestBase classGenerator = CreateNewClassGenerator();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            classGenerator.Compile();
            string fileContents = classGenerator.FileContents;

            //---------------Test Result -----------------------
            StringAssert.Contains("using Habanero.BO;", fileContents);
            //StringAssert.Contains(string.Format("namespace {0}", classGenerator.ProjectName), fileContents);
            StringAssert.Contains("public class TestBase", fileContents);
            //TODO check connection string set correctly
        }
        //        public class TestBoTestProjectGenerator_GeneratedFile_TestBaseClass : TestBoTestProjectGenerator_GeneratedFile
        //        {
        //            private const string _className = "TestBase";

        //            protected override string GetFileName()
        //            {
        //                return _className + ".cs";
        //            }
        //        }

        [Test]
        public void Test_Generate()
        {
            //The Generate method should take the results of the compile method and write them to a file.
            // The conttents of the file should only be written if the file does not already exist.
            //---------------Set up test pack-------------------
            ClassGeneratorTestBase classGenerator = CreateNewClassGenerator();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------

            //---------------Test Result -----------------------

        }

        private static ClassGeneratorTestBase CreateNewClassGenerator()
        {
            string fileName = TestUtilsCodeGen.GetRandomString();
            string projectName = TestUtilsCodeGen.GetRandomString();
            string projectPath = TestUtilsCodeGen.GetRandomString();
            return new ClassGeneratorTestBase(fileName, projectName, projectPath);
        }
    }
}